public class TestOne {
    public static int Sum(int num){
        if(num<10){
            return num;
        }
        return (num%10)+Sum(num/10);
    }

    public static int Fib(int num){
        if(num==1){
            return 0;
        }
        if(num==2){
            return 1;
        }
            return Fib(num-1)+Fib(num-2);

    }
    public static int Fib1(int num){
        if(num==1){
            return 0;
        }
        if(num==2){
            return 1;
        }
        int f1=0;
        int f2=1;
        int f3=-1;
        for (int i = 3; i <= num; i++) {
            f3=f1+f2;
            f1=f2;
            f2=f3;
        }
        return f3;
    }
    public static void main(String[] args) {
        //System.out.println(Sum(123));
        //System.out.println(Fib(1));
        System.out.println(Fib1(8));
    }

    public static void main2(String[] args) {
        int a=1;
        long l=6;
        //a=a+l;报错
        a+=l;//这种运算符会自动帮我们进行类型转换
    }
    public static void main1(String[] args) {
        System.out.println(10%3);
        System.out.println(10%-3);
        System.out.println(-10%3);
        System.out.println(-10%-3);
        //在java中模除可以使用小数
        System.out.println(11.5%2);
    }
}
